" Options
set adblocker=update
set devtoolsposition=split
set downloadmethod=confirm
set followchars=numbers
set guifontsize=16
set mapsuggestposition=bottomleft
set permissioncamera=ask
set permissiondisplaycapture=ask
set permissionmediadevices=allow
set permissionmicrophone=ask
set permissionpersistentstorage=allow
set redirecttohttp
set restoretabs=pinned
set tabclosefocus=right
set tabreopenposition=right
set useragent=%firefox
set windowtitle="%title - %app"

" Custom Commands
command! set_ <:help>
command! download <:write>
command! navigate_prev <previousPage>
command! navigate_prev_--tab <previousPageNewTab>
command! navigate_next <nextPage>
command! navigate_next_--tab <nextPageNewTab>
command! navigate_up_--tab <openNewTabWithCurrentUrl><CR><toParentUrl>
command! tab-focus_1 <:b 0>
command! tab-focus_-1 <:b -1>
command! tab-focus_last <:buffer #>
command! open_--tab <:tabnew>
command! open_--tab_--_{clipboard} <:tabnew><openFromClipboard>
command! tab-clone <openNewTabWithCurrentUrl><CR>
command! tab-move_+ <moveTabForward>
command! tab-move_- <moveTabBackward>
command! tab-only <:lclose><:rclose>
command! zoom <zoomReset>
command! tab-pin <:pin>
command! stop <stopLoadingPage>
command! set-cmd-text_--space_open_--tab <:tabnew><toExploreMode>
command! set-cmd-text_--space_open <toExploreMode><BS>
command! set-cmd-text_open_{urlpretty} <toExploreMode><End>
command! set-cmd-text_--space_tab-select <toCommandMode>buffer<Space>
command! yank_selection <p.copyText>
command! open_--_{clipboard} <openFromClipboard>
command! set-cmd-text_--space_bind <toCommandMode>map<Space>
command! set-cmd-text_--space_set <toCommandMode>set<Space>
command! edit-text <editWithVim>
command! rl-beginning-of-line <Home>
command! rl-end-of-line <End>
command! rl-forward-word <C-Right>
command! rl-backward-word <C-Left>
command! rl-kill-word <C-S-Right><BS>
command! rl-backward-kill-word <C-S-Left><BS>
command! rl-delete-char <Del>
command! rl-backward-delete-char <BS>
command! rl-backward-char <Left>
command! rl-forward-char <Right>
command! rl-kill-line <S-End><BS>
command! rl-unix-line-discard <S-Home><BS>
command! rl-unix-word-rubout <C-S-Left><BS>
command! completion-item-focus_next-category <nextSuggestionSection>
command! completion-item-focus_prev-category <prevSuggestionSection>
command! mode-enter_normal <toNormalMode>
command! move-to-end-of-word <p.moveFastRight>
command! selection-toggle_ <p.startVisualSelect>
command! selection-toggle <p.start>
command! selection-drop <toNormalMode><p.start><p.startVisualSelect>

" Mappings
nmap wi <:devtools>
nmap Sh <:history>
nmap Ss <:set_>
nmap <C-A-p> <:print>
nmap <C-W> <:quit>
nmap ZQ <:quit>
nmap gd <:download>
nunmap [
nunmap ]
nunmap {
nunmap }
nmap [[ <:navigate_prev>
nmap ]] <:navigate_next>
nmap {{ <:navigate_prev_--tab>
nmap }} <:navigate_next_--tab>
nmap gU <:navigate_up_--tab>
nmap g0 <:tab-focus_1>
nmap g^ <:tab-focus_1>
nmap g$ <:tab-focus_-1>
nmap <C-^> <:tab-focus_last>
nmap <C-Tab> <:tab-focus_last>
nmap ga <:open_--tab>
nmap gC <:tab-clone>
nmap gJ <:tab-move_+>
nmap gK <:tab-move_->
nmap <C-S-PageUp> <:tab-move_+>
nmap <C-S-PageDown> <:tab-move_->
" This is disabled as it prevents use of window split mappings.
" See :h splitting for more information on window splits
" nmap <C-w> <:close>
nmap co <:tab-only>
nmap = <:zoom>
nmap <C-p> <:tab-pin>
nmap <C-s> <:stop>
nmap o <:set-cmd-text_--space_open>
nmap go <:set-cmd-text_open_{urlpretty}>
nmap gt <:set-cmd-text_--space_tab-select>
nmap O <:set-cmd-text_--space_open_--tab>
nunmap p
nmap pp <:open_--_{clipboard}>
nmap Pp <:open_--tab_--_{clipboard}>
nmap sk <:set-cmd-text_--space_bind>
nmap ss <:set-cmd-text_--space_set>

imap <C-e> <:edit-text>

cmap <C-a> <:rl-beginning-of-line>
cmap <C-e> <:rl-end-of-line>
cmap <A-f> <:rl-forward-word>
cmap <A-b> <:rl-backward-word>
cmap <A-d> <:rl-kill-word>
cmap <A-BS> <:rl-backward-kill-word>
cmap <C-?> <:rl-delete-char>
cmap <C-h> <:rl-backward-delete-char>
cmap <C-b> <:rl-backward-char>
cmap <C-f> <:rl-forward-char>
cmap <C-k> <:rl-kill-line>
cmap <C-u> <:rl-unix-line-discard>
cmap <C-w> <:rl-unix-word-rubout>
cmap <C-e> <:edit-text>

emap <C-e> <:edit-text>
emap <C-Tab> <:completion-item-focus_next-category>
emap <C-S-Tab> <:completion-item-focus_prev-category>

smap <C-e> <:edit-text>

pmap c <:mode-enter_normal>
pmap e <:move-to-end-of-word>
pmap H <:scroll_left_>
pmap L <:scroll_right_>
pmap <Space> <:selection-toggle_>

vmap v <:selection-toggle>
vmap <CR> <:yank_selection>
vmap <C-Space> <:selection-drop>

" vim: ft=vim
